package com.fengye.common.controller;

import jakarta.servlet.http.HttpSession;

/**
 * @author 枫叶fy
 * @description 控制层基类
 * @since 2024/2/25 01:01
 */
public class BaseController {
    // 不可变的常量
    public static final int kSuccessState = 200;
    /**
     * 获取当前登录用户的uid
     * @param session 会话
     * @return uid
     */
    protected final Integer getUidFromSession(HttpSession session) {
        return Integer.valueOf(session.getAttribute("uid").toString());
    }

    /**
     * 获取当前登录对象的username
     * @param session 会话
     * @return username
     */
    protected final String getUsernameFromSession(HttpSession session) {
        return session.getAttribute("username").toString();
    }
}
